package com.jvm123.blog.controller

import com.jvm123.blog.dao.CollectRepos
import com.jvm123.blog.entity.Collect
import com.jvm123.blog.entity.Term
import com.jvm123.blog.service.CollectService
import com.jvm123.blog.service.TermService
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 *
 * @author yawn
 *     2019/10/6 18:54
 */
@RestController
@RequestMapping("admin/rest")
class AdminRestController {

    @Autowired
    TermService termService
    @Autowired
    CollectService collectService
    @Autowired
    CollectRepos collectRepos

    Logger logger = LoggerFactory.getLogger(AdminRestController.class)

    @GetMapping("distinct/categories")
    Set<Term> distinctCategories() {
        termService.findCategories()
    }

    @GetMapping("distinct/tags")
    Set<Term> distinctTags() {
        termService.findTags()
    }

    @GetMapping("collect/{id}")
    Collect getCollect(@PathVariable("id") Long id) {
        collectService.findOne(id)
    }
}
